<template>
  <el-dialog
    v-el-drag-dialog
    class="XiaoDanDialog"
    :title="title"
    :visible.sync="isShow"
    width="500px"
    append-to-body
    @closed="close"
  >
    <div class="tc f16">
      <p>本期应收款与本期核销款有</p>
      <p class="mt10 mb10" style=" font-size: 30px; color: red;">{{ money }}</p>
      <p>差额，请选择：</p>
    </div>
    <div class="tc mt20">
      <span>挂账机构：</span>
      <el-select v-model="orgId" class="mr10">
        <el-option
          v-for="(item, index) in orgList"
          :key="index"
          :label="item.orgName"
          :value="item.orgId"
        />
      </el-select>
    </div>
    <div class="tc mt20">
      <el-button type="primary" class="f16" @click="xiaodna(2)"> 结转差额 </el-button>
      <el-button v-if="money > 0" type="primary" class="f16" @click="xiaodna(3)"> 减免上报 </el-button>
      <el-button v-else type="primary" class="f16" @click="xiaodna(4)"> 减免差额 </el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { queryMonthAccCsmMonthlyTrackXiaodanOrg } from '@/api'
  export default {
    data() {
      return {
        isShow: false,
        orgId: '',
        billCode: '',
        money: 0,
        orgList: []
      }
    },
    computed: {
      title() {
        return `销单--${this.billCode}`
      }
    },
    methods: {
      show(billCode, money, superviseSettingList) {
        this.money = money
        this.billCode = billCode
        this.getOrgList()
        this.isShow = true
      },
      xiaodna(type) {
        const data = {
          orgId: this.orgId,
          type: type
        }
        this.$emit('submit', data)
      },
      async getOrgList() {
        const params = {
          billCode: this.billCode
        }
        const { status, data } = await queryMonthAccCsmMonthlyTrackXiaodanOrg(params)
        if (status === 200) {
          this.orgList = data
        }
      },
      close() {
        this.isShow = false
        this.money = 0
        this.billCode = ''
        this.orgList = []
      }
    }
  }
</script>

<style lang="scss" scoped></style>
